home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 689 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.0 KB  |  37 lines

  1. Path: sarah.netmedia.co.il!usenet
  2. From: davidb@netmedia.co.il (davidb)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: Re: -> How do you use the EXTERN keyword? <-
  5. Date: Fri, 05 Jan 1996 21:00:30 GMT
  6. Organization: NetMedia
  7. Message-ID: <4ck798$ju@sarah.netmedia.co.il>
  8. References: <4chkq2$1s06@pulp.ucs.ualberta.ca>
  9. NNTP-Posting-Host: cs31a3.netmedia.net.il
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. jbukczyn@gpu.srv.ualberta.ca (Jacob Bukczynski) wrote:
  13.  
  14. >I need to use variables in two different source files in the
  15. >same project. I know that you need to declare them somehow
  16. >with the EXTERN keyword but I don't know how. 
  17.  
  18. >Please help! Reply by email if possible, or just follow-up
  19. >here. Thanks in advance.
  20.  
  21. Declare the variables in a header file eg data.h:
  22.  
  23. extern int myInteger
  24.  
  25. You #include the above header file in all the source files in which
  26. you need to access the integer. In one of the source files you also
  27. define and initialise the integer outside a function body...
  28.  
  29. int myInteger = 0;     \\ or any other number
  30.  
  31. That's all there is to it
  32.  
  33. David Becher
  34.  
  35.  
  36.  
  37.